<%@page import="com.sdry.entity.permission.UpmsStaffRole"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>


  <meta charset="utf-8" />
  <meta http-equiv="X-UA-Compatible" content="IE=edge" />
  <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport" />
  <title>备品备件管理系统</title>
  <link href="${pageContext.request.contextPath}/Lanai/css/lanai-ui.css" rel="stylesheet" />
  <script type="text/javascript" src="${pageContext.request.contextPath }/Lanai/js/jquery.min.js"></script>
   <%
 	 	UpmsStaffRole use = (UpmsStaffRole)session.getAttribute("user");
 	 	Long d = null;
  	 	String name = null;
  	 	String scode = null;
  	 	Long staffId = null;
  	 	if(use != null){
  	 		d = use.getRoleId();
  	 		name = use.getUpmsStaff().getSname();
  	 		scode = use.getUpmsStaff().getScode();
  	 		staffId = use.getUpmsStaff().getStaffId();
  	 	}
	%>
</head>

<body class="hold-transition skin-blue sidebar-mini">
<div class="wrapper">
  <!-- Main Header -->
  <header class="main-header">
    <!-- Logo -->
    <a href="${pageContext.request.contextPath}/login/toLogin.do" class="logo">
      <!-- mini logo for sidebar mini 50x50 pixels -->
      <span class="logo-mini"><b>L</b>AI</span>
      <!-- logo for regular state and mobile devices -->
      <span class="logo-lg"><b>备品备件管理系统</b></span>
    </a>
    <!-- Header Navbar -->
    <nav class="navbar navbar-static-top" role="navigation">
      <!-- Sidebar toggle button-->
      <a href="#" class="sidebar-toggle" data-toggle="push-menu" role="button">
        <span class="sr-only">Toggle navigation</span>
      </a>
      <!-- Navbar Right Menu -->
      <div class="navbar-custom-menu">
        <ul class="nav navbar-nav">
          <li class="dropdown notifications-menu">
            <!-- Menu toggle button -->
            <a href="#" onclick="upPass()" class="dropdown-toggle" data-toggle="dropdown">
              <i class="fa fa-bell-o"></i>
              密码管理
              <!-- <span class="label label-warning">1</span> -->
            </a>
            <script type="text/javascript">
                function upPass() {
                	$('#exampleModal').modal(open);
				}
            </script>
            <!-- <ul class="dropdown-menu">
              <li class="header">警示信息 </li>
              <li>
                Inner Menu: contains the notifications
                <ul class="menu">
                  <li>
                    start notification
                    <a href="#" onclick="upPass()">
                      <i class="fa fa-users text-aqua"></i> 信息内容
                    </a>
                    <script type="text/javascript">
                    	function upPass() {
                    		$('#exampleModal').modal(open);
						}
                    </script>
                  </li>
                  end notification
                </ul>
              </li>
              <li class="footer"><a href="#">查看</a></li>
            </ul> -->
          </li>
          <!-- User Account Menu -->
          <li class="user user-menu">
            <!-- Menu Toggle Button -->
            <a href="#" >
              <!-- The user image in the navbar-->
              <img src="Lanai/img/sl.jpg" class="user-image" alt="User Image" />
              <!-- hidden-xs hides the username on small devices so only the image appears. -->
              <span class="hidden-xs"><%=name%></span>
            </a>
          </li>
        </ul>
      </div>
    </nav>
  </header>
  <!-- 左菜单-->
  <!-- Left side column. contains the logo and sidebar -->
  <aside class="main-sidebar">
    <!-- sidebar: style can be found in sidebar.less -->
    <section class="sidebar">
      <!-- Sidebar Menu -->
      <ul class="sidebar-menu" data-widget="tree"></ul>
      <script>
          $(function () {
        	var roleId = <%=d%>;
			
            //$.getJSON('${pageContext.request.contextPath }/js/menuList.json',function(data){
            //$.post("${pageContext.request.contextPath }/upmsPermission/queryAll.do", "ids="+ids, function(data) {
            $.ajax({
              type: "post",
              /* url: "${pageContext.request.contextPath }/upmsPermission/queryAll.do", */
              data: "roleId="+roleId+"&upmsPermission.status=1",
         	  url: "${pageContext.request.contextPath }/UpmsRolePermission/queryAll.do",
              dataType: 'JSON',
              async: false,
              success: function (data) {
              	var $li,$menu_f_ul,$menu_s;
                  var listId = new Array();
                  //放入大标签
                  $.each(data,function(index,items){
                  	var item = items.upmsPermission;
                      if(item.pid == null || item.pid == ""){
                          $li=$('<li class="treeview"></li>');

                          var $menu_f=$('<a href="#">\n'+
                              '<i class="'+"fa "+item.icon+'"></i> <span>'+item.name+'</span>\n'+
                              ' <span class="pull-right-container">\n'+
                              '<i class="fa fa-angle-left pull-right"></i>\n'+
                              '</span></a>');
                          $li.append($menu_f);
                          $menu_f_ul=$('<ul class="treeview-menu" id="'+item.permissionId+'"></ul>');
                          $li.append($menu_f_ul);
                          $("ul.sidebar-menu").append($li);

                          listId.push(item.permissionId);
                      }

                  });
                  //放入小标签
                  for(var i=0;i<listId.length;i++){
                      $.each(data,function(index,items){
                      	var item = items.upmsPermission;
                          if(item.pid != null && item.pid == listId[i]){
                              var id = "ul.treeview-menu#"+listId[i];
                              $menu_s = $('<li><a href="#" data-addtab="'+item.permissionId+'"  data-target="#MasterTabs" data-title="'+item.name+'" data-url="'+item.uri+'"><i class="'+"fa "+item.icon+'"></i>' + item.name + '</a></li>');
                              //$menu_s = $('<li><a href="javascript:void(0)" onclick="createMuIcon(\''+item.uri+'\',\''+item.name+'\')"><i class="'+item.icon+'"></i>' + item.name + '</a></li>');
                              $(id).append($menu_s);
                          }
                      });
                  }
             	}
             });
              
          });
      </script>
      <!-- 菜单下界 -->
      <!-- /.sidebar-menu -->

      <div class="sidebar-footer hidden-small fadeInLeft animated">
        <!-- 根据data-widget刷新中心界面打开页面    laian-ui.js写死的-->
        <a data-toggle="tooltip" data-placement="top" data-original-title="refresh" data-widget="tooltip-refresh">
          <span class="fa fa-refresh" aria-hidden="true"></span>
        </a>
        <!-- 根据data-widget全屏    laian-ui.js写死的-->
        <a id="fullscreen" data-toggle="tooltip" data-placement="top" title="" data-original-title="FullScreen" data-widget="tooltip-fullscreen">
          <span class="fa fa-arrows-alt" aria-hidden="true"></span>
        </a>
        <!--根据data-widget打开id为modal的div   laian-ui.js写死的-->
        <a id="lockpage" data-toggle="tooltip" data-placement="top" title="" data-original-title="Lock" data-widget="tooltip-lock">
          <span class="fa fa-eye-slash" aria-hidden="true"></span>
        </a>
        <!--关闭退出-->
        <a data-toggle="tooltip" data-placement="top" title="" href="${pageContext.request.contextPath}/login/toLogin.do" data-original-title="Logout">
          <span class="fa fa-power-off" aria-hidden="true"></span>
        </a>
      </div>
    </section>
    <!-- /.sidebar -->
  </aside>
  <!-- Content Wrapper. Contains page content -->

  <!-- 中心 -->
  <div class="content-wrapper">
    <!-- Main content -->
    <section class="content container-fluid" style="padding:0px">
      <ul class="nav nav-tabs menu-tabs" id="MasterTabs" role="tablist">
        <li class="nav-tabs-header active" role="presentation">
          <a aria-controls="home" data-toggle="tab" href="#home" role="tab">
            <i class="fa fa-home"></i> Home
          </a>
        </li>
      </ul>
      <!-- Tab panes -->
      <div class="tab-content fixheight">
        <div class="tab-pane active" id="home" role="tabpanel">
        </div>
      </div>
    </section>
    <!-- /.content -->
  </div>

  <!-- 下标签-->
  <!-- /.content-wrapper -->
  <!-- Main Footer -->
  <footer class="main-footer">
    <!-- To the right -->
    <div class="pull-right hidden-xs">
      <b>Version</b> 1.0.0.1
    </div>
    <!-- Default to the left -->
    <strong>北京盛达融元 © 2017-2018 .</strong> All rights reserved.
  </footer>
  <!--Small Chat-->
  <div class="box small-chat-box direct-chat direct-chat-primary  fadeInRight animated" data-widget="chat-small-box">
    <div class="box-header with-border">
      <h3 class="box-title" id="chatTitle">LAI聊</h3>
      <div class="box-tools pull-right">
        <button type="button" id="btn_showContacts" class="btn btn-box-tool" data-toggle="tooltip" title="" data-widget="chat-pane-toggle" data-original-title="Contacts">
          <i class="fa fa-comments"></i>
        </button>
      </div>
    </div>

    <div class="chat-area">
      <span class="badge badge-warning pull-right msgCount">2</span>
      <a class="open-small-chat" data-widget="chat-small-open">
        <i class="fa fa-comments"></i>
      </a>
    </div>
    <!-- /. Chat-Area-->
  </div>
  
  <div class="modal fade" id="exampleModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel">
   		<div class="modal-dialog" role="document">
    		<div class="modal-content">
      			<div class="modal-header">
        			<button type="button" class="close closefm" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
        			<h4 class="modal-title" id="exampleModalLabel">
        				<span style="font-size:13px">修改密码</span>
        			</h4>
      			</div>
      			<div class="modal-body">
	          		<form id="fm" class="form-horizontal">
	          			<div class="form-group">
							<label class="col-sm-2 control-label">密码:</label>
							<div class="col-sm-8"> 
								<input type="password" name="pass" id="pass" class="col-xs-12 col-sm-4 form-control"/>
	          				</div>
						</div>
	          			<div class="form-group">
							<label class="col-sm-2 control-label">确认密码:</label>
							<div class="col-sm-8"> 
								<input type="password" name="pass2" id="pass2" class="col-xs-12 col-sm-4 form-control"/>
							</div>
						</div>
	          			
	        		</form>
	      		</div>
       			<div class="modal-footer"> 
					<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
				    <button type="submit" class="btn btn-primary submit" onclick="save()">保存</button>
	      		</div>
    		</div>
  		</div>
	</div>
  <script type="text/javascript">
  $(function () {
		//初始化提示框的位置：top-center，bottom-left，bottom-right
	    toastr.options.positionClass = 'toast-top-center';
		//模态框关闭事件
	    $('#exampleModal').on('hide.bs.modal',function(){
	    	//表单清空
	    	$("#fm")[0].reset();
	    });
	  	//jQuery，既阻止默认行为又停止冒泡  导入按钮
	    $(".submit").on('click',function(){
	    	    return false;//当然 也阻止了事件本身
	    });

	});
	//表单提交
  function save() {
		
	  	var pass = $("#pass").val();
	  	var pass2 = $("#pass2").val();
	  	if(pass == "" || pass == null){
	  		toastr.error("密码不能为空！");
	  	}else if(pass != pass2){
	  		toastr.error("请确认密码！");
	  	}else{
		  	pass = md5($("#pass").val());
		  	var data = "staffId="+<%=staffId%>+"&pass="+pass;
	  		var url = "${pageContext.request.contextPath }/upmsStaff/update.do";
	  		var title = "修改"; 
	  	    $.post(url, data, function(data) {
	  			if (data == 1) {
	  				toastr.success(title+'成功');
	  				setTimeout(function(){  //使用  setTimeout（）方法设定定时2000毫秒
	  					$('#exampleModal').modal('hide');
	  					$('#tb_table').bootstrapTable('refresh');  
	  					refresh();
	  				},1000);
	  			} else {
	  				toastr.error(title+'失败');
	  			}
	  		});
	  	}
  }
  </script>
  <%--锁屏后弹出的界面--%>
  <!-- ./wrapper -->
  <div id="modal" class="hold-transition lockscreen" style="display:none">
    <div class="lockscreen-wrapper">
      <div class="lockscreen-logo">
        <a href="#"><b>备品备件</b>管理系统</a>
      </div>
      <div class="lockscreen-name"><span><%=name%></span></div>
      <div class="lockscreen-item">
        <div class="lockscreen-image">
          <img src="Lanai/img/sl.jpg" />
        </div>
        <form class="lockscreen-credentials">
          <div class="input-group">
            <input id="tbx_lock_password" type="password" class="form-control" placeholder="password" value="">
            <input type="hidden" id="tbx_lock_name" value="<%=scode%>">

            <div class="input-group-btn">
              <!--点击根据data-widget关闭modal -->
              <button type="button" class="btn" onclick="pageGodEntry()" data-placement="top" title=""><i class="fa fa-arrow-right text-muted"></i></button>
              <button type="button" id="unlock" style="display:none;" class="btn" data-widget="tooltip-unlock" data-placement="top" title=""><i class="fa fa-arrow-right text-muted"></i></button> 
            </div>
          </div>
        </form>
      </div>
      <div class="help-block text-center">
        输入密码解除锁定
      </div>
      <div class="lockscreen-footer text-center">
        <span id="nameerr"></span>
      </div>
    </div>
  </div>
  <script type="text/javascript" src="${pageContext.request.contextPath}/js/md5.js"></script>
  <script type="text/javascript">
  
  function pageGodEntry() {
      var scode = $("#tbx_lock_name").val();
      var pass = $("#tbx_lock_password").val();
      if(pass == "" || pass == null){
    	  $("#nameerr").html("请输入密码！");
    	  return;
      }
      pass = md5($("#tbx_lock_password").val());
      $.ajax({
          type: "POST",
          url:"${pageContext.request.contextPath}/login/login.do",
          data:"scode="+scode+"&pass="+pass,
          success: function(data) {
          	if (data == 0) {
					$("#nameerr").html("密码不正确！");
				}else {
					$("#tbx_lock_password").val("");
					document.getElementById("unlock").click();
				}
          }
      }); 
  }
  </script>
  
  <!-- ./ 锁定屏幕 -->
  <script src="${pageContext.request.contextPath}/Lanai/js/jquery.min.js"></script>
  <script src="${pageContext.request.contextPath}/Lanai/js/lanai-ui.js"></script>
</div>
</body>
</html>